<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/24/024
 * Time: 20:12
 */

namespace app\admin\validate;

class ProblemValidate extends \think\Validate
{

    const SCENE_ADD = 'add'; //添加
    const SCENE_EDIT = 'edit'; //编辑
    const SCENE_REMOVE = 'remove'; //删除


    protected $rule = [
        'id' => 'require|number',
        'type' => 'require|number',
        'name'  =>  'require|max:32',
        'content' =>  'require',
        'sort' =>  'require|number', 
    ];


    protected $message  = [
        'type.require' => '类型必须',
        'type.number' => '必须为数字',
        'name.require' => '标题必须',
        'name.max' => '标题最大长度为32',
        'content.require' => '内容必须',
        'sort.require' => '排序值必须',
        'sort.number' => '排序值为数字',
    ];
    
    //场景
    protected $scene  = [
       self::SCENE_ADD => ['type', 'name', 'content'],
       self::SCENE_EDIT => ['id', 'type', 'name', 'content'],
       self::SCENE_REMOVE => ['id'],
    ];



}